#include"BinTree.h"

void Check(BTN* P)
{
	if (P == NULL)
	{
		printf("malloc fail\n");
		exit(-1);
	}
}

void TestTree(BTN* A)
{
	PrevOrder(A);
	printf("\n");
	InOrder(A);
	printf("\n");
	PostOrder(A);
	printf("\n");
	int Asize = 0;
	TreeSize1(A, &Asize);
	printf("%d\n ", Asize);
	printf("%d\n", TreeSize2(A));
}

int main()
{
	BTN* A = (BTN*)malloc(sizeof(BTN));
	Check(A);
	A->left = NULL;
	A->right = NULL;
	A->data = 'A';

	BTN* B = (BTN*)malloc(sizeof(BTN));
	Check(B);
	B->left = NULL;
	B->right = NULL;
	B->data = 'B';

	BTN* C = (BTN*)malloc(sizeof(BTN));
	Check(C);
	C->left = NULL;
	C->right = NULL;
	C->data = 'C';

	BTN* D = (BTN*)malloc(sizeof(BTN));
	Check(D);
	D->left = NULL;
	D->right = NULL;
	D->data = 'D';

	BTN* E = (BTN*)malloc(sizeof(BTN));
	Check(E);
	E->left = NULL;
	E->right = NULL;
	E->data = 'E';

	A->left = B;
	A->right = C;
	B->left = D;
	B->right = E;
	TestTree(A);
	return 0;
}